package com.project.card.util;

import java.security.MessageDigest;

public class MD5Util {
    public static String encrypToMD5(String string){
        byte[] hash = {};
        try{
            hash = MessageDigest.getInstance("MD5").digest(string.getBytes());
        }catch (Exception e){
            e.printStackTrace();
        }
        StringBuilder hexStringBuilder = new StringBuilder(hash.length * 2);
        for(byte b :hash){
            if((b & 0xFF)< 0x10){
                hexStringBuilder.append(0);
            }
            hexStringBuilder.append(Integer.toHexString(b & 0xff));
        }
        return hexStringBuilder.toString().toUpperCase();
    }
}
